// https://www.programmercarl.com/0024.%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.html#%E7%AE%97%E6%B3%95%E5%85%AC%E5%BC%80%E8%AF%BE
// https://leetcode.cn/problems/swap-nodes-in-pairs/description/

const swapPairs = function(head) {
  const dummyNode = new ListNode(0);
  dummyNode.next = head;
  let temp = dummyNode;
  while (temp.next && temp.next.next) {
    let pre = temp.next;
    let cur = temp.next.next;
    pre.next = cur.next
    cur.next = pre;
    temp.next = cur;
    temp = pre;
  }
  return dummyNode.next;
};

